const g = getApp().globalData
const util = g.util

Page({

    data: {
        tabSelected: [true, false, false, false], //三个tab的显隐控制属性
        swiperCurrent: 0,
        swiperHeight: 0,//滑块高度

        noHandleList: [],
        noHandleBottomHidden: false,
        noHandleGifShow: true,
        noHandleHasData: true,

        ownerApplyList: [],
        ownerApplyBottomHidden: false,
        ownerApplyGifShow: true,
        ownerApplyHasData: true,

        managerApplyList: [],
        managerApplyBottomHidden: false,
        managerApplyGifShow: true,
        managerApplyHasData: true,

        rejectList: [],
        rejectBottomHidden: false,
        rejectGifShow: true,
        rejectHasData: true,

    },

    onLoad() {
        this.getWindowHeight()
        this.getApprovalList()
    },

    getApprovalList() {
        let url = `approve/list?page=1&page_size=20&status=0`
        this.noHandleRequestBack = false
        util.httpGet({
            url,
            header: { authorization: g.userInfo.token },
            fn: res => {
                let noHandleList = res.data.result.rows
                this.setData({
                    noHandleList
                })
            },
            comFn: res => {
                this.noHandleRequestBack = true
            }
        })
    },

    chooseTab: function (e) {
        //选择选项事件
        var index = e.currentTarget.dataset.index
        this.istabtap = true
        this.changeTab(index)
    },
    changeTab: function (index) {
        for (var i in this.data.tabSelected) {
            this.data.tabSelected[i] = (i == index)
        }
        this.setData({
            tabSelected: this.data.tabSelected,
            swiperCurrent: index
        })
    },
    swiperchange: function (e) {
        if (this.istabtap) {
            this.istabtap = false
        }
        else {
            var index = e.detail.current
            this.changeTab(index)
        }
    },

    getWindowHeight: function () {
        let systemInfo = wx.getSystemInfoSync()
        let swiperHeight = 0
        swiperHeight = Math.ceil(systemInfo.windowHeight * g.px2rpx - 80)
        this.setData({
            swiperHeight: swiperHeight,
        })
    },
})